<template>
	<view class="orderAdd">
		<uv-navbar title="跟进记录" titleStyle="color:#fff" leftIconColor="#fff" bgColor="#1071E7" @leftClick="leftClick"
			placeholder>
		</uv-navbar>
		<view class="block">
			<view class="block-title">
				接单人
			</view>
			<view class="block-item">
				<view class="label">沟通方式</view>
				<view class="block-item-fr flex align-center" @click="openPicker">
					<text class="styles"
						:class="connect_type_name?'ipt':''">{{connect_type_name?connect_type_name:'请选择'}}</text>
					<image class="arrow" src="../../static/images/arrow.png" mode=""></image>
				</view>
			</view>
		</view>
		<view style="width: 100%;height: 24rpx;background: #f5f5f5;"></view>
		<view class="block">
			<view class="block-warp">
				<view class="block-warp-tp">
					<view class="tp-fl">
						请输入跟进内容
					</view>
<!-- 					 <view class="tp-fr">
					 	{{formLine.content.length}}/200
					 </view> -->
				</view>
				<textarea class="textareaIpt" maxlength="-1" v-model="formLine.content" placeholder="请输入"
					placeholder-style="styles"></textarea>
			</view>
			<view class="block-warp">
				<view class="block-warp-tp" style="margin: 48rpx 0 24rpx 0">
					<view class="tp-fl">
						上传聊天记录（{{formLine.images.length}}/9)
					</view>
				</view>
				<UploadImgs :imgList="imgList" keyName="images" @getUrl="getUrl" />
			</view>
			<view style="width: 100%;height: 100rpx;"></view>
		</view>
		<view class="footer">
			<view class="btn" @click="onSave">
				发布
			</view>
		</view>
		<uv-picker ref="picker" :columns="columns" keyName="title" @confirm="confirm"></uv-picker>
	</view>
</template>

<script>
	import reqApi from "../../api/api.js";
	export default {
		data() {
			return {
				formLine: {
					id: "",
					images: [],
					content: "",
					connect_type: ""
				},
				connect_type_name: "",
				columns: [
					[{
							title: "电话",
							id: 1
						},
						{
							title: "微信",
							id: 2
						},
						{
							title: "QQ",
							id: 3
						},
						{
							title: "其他",
							id: 4
						}
					]
				],
			}
		},
		onLoad(option) {
			this.formLine.id = option.id;
		},
		methods: {
			leftClick() {
				uni.navigateBack({
					delta: 1
				})
			},
			handleOk() {
				this.$refs.popup.close();
			},
			onSave() {
				reqApi.addRecord(this.formLine).then(res => {
					uni.showToast({
						title: "发布成功",
						icon: 'none',
						mask: true,
						duration: 1500,
					})
					setTimeout(() => {
						uni.navigateTo({
							url: `/pages/order/takeOrderDetail?id=${this.formLine.id}`
						})
					}, 1500)
				})
			},
			confirm(e) {
				console.log('confirm', e);
				const {
					id,
					title
				} = e.value[0];
				this.formLine.connect_type = id;
				this.connect_type_name = title;
			},
			openPicker() {
				this.$refs.picker.open();
			},
			getUrl(e) {
				console.log("子组件传过来的", e);
				const {
					keyName,
					arr
				} = e;
				this.formLine[keyName] = arr;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.dialog {
		width: 600rpx;
		padding: 48rpx 28rpx 0 28rpx;
		box-sizing: border-box;

		.dialog-title {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #1071E7;
			text-align: center;
		}

		.dialog-warpp {
			margin: 50rpx 0;

			.dialog-warpp-item {
				display: flex;
				justify-content: space-between;
				margin-bottom: 16rpx;

				.label {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #969799;
				}

				.value {
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #323233;
				}
			}
		}

		.foot-btn {
			width: 100%;
			height: 88rpx;
			background: #1071E7;
			border-radius: 44rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 88rpx;
		}
	}

	.textareaIpt {
		width: 100%;
		padding: 24rpx 0;
		box-sizing: border-box;
		border-bottom: 2rpx solid #eee;
	}

	.block-warp {
		.block-warp-tp {
			display: flex;
			justify-content: space-between;

			.tp-fl {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #323233;
			}

			.tp-fr {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #969799;
			}
		}
	}

	.styles {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #969799;
	}

	.ipt {
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #222;
		text-align: right;
	}

	.orderAdd {
		width: 100vw;
		height: calc(100vh - 88rpx);
		background: #fff;

		.block {
			padding: 30rpx;
			background: #fff;

			.block-title {
				font-family: PingFangSC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #323233;
			}

			.block-item {
				display: flex;
				justify-content: space-between;
				margin-top: 30rpx;

				.label {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #323233;
				}

				.block-item-fr {
					flex: 1;
					justify-content: flex-end;
					display: flex;

					.arrow {
						width: 48rpx;
						height: 48rpx;
					}

				}
			}
		}
	}
</style>
